Bag template.
More...
#include <tbag.h>
Public Types |
typedef uint32(* | THashFunc )(const T &, uint32) |
| Hash function type.
|
Public Member Functions |
| TBag (int32 size=10) |
| Bag constructor.
|
| TBag (THashFunc hashFunction, int32 size=10) |
| Bag constructor with a specified hash function.
|
| TBag (THashTable< T > &hashTable) |
| Bag copy constructor.
|
| TBag (THashFunc hashFunction, const TContainer< T > &container) |
| Bag constructor with a specified hash function and a container.
|
TBag< T > & | operator= (const THashTable< T > &hashTable) |
| Assignment operator.
|
virtual bool | add (const T &item) |
| Adds a new item to the bag.
|
virtual bool | add (const T &item, int32 numCopies) |
| Adds a number of copies of a new item to the bag.
|
virtual bool | remove (const T &item) |
| Removes the first occurrence of an item from the bag.
|
virtual bool | remove (const T &item, int32 numCopies) |
| Removes a number of copies of an item from the bag.
|
virtual void | removeAll (const T &item) |
| Removes all occurrences of the specific item from the bag.
|
virtual void | removeAll () |
| Removes all items from the bag.
|
int32 | getCount (const T &item) |
| Number of occurrences (cardinality) of the given item.
|
THashSet< T > * | createUniqueSet () |
| Creates a hash set of unique items.
|
Detailed Description
template<class T>
class Steinberg::TBag< T >
Bag template.
A bag is a hash table that adds a few convenient functions to the super class, regarding the handling of identical items
- See also:
- THashTable, THashSet
Member Typedef Documentation
typedef uint32(* THashFunc)(const T &, uint32) |
Constructor & Destructor Documentation
TBag |
( |
int32 |
_size = 10 |
) |
[inline] |
Bag constructor.
Before using this bag, a hash function has to be assigned via the THashTable<T>::setHashFunction() method
- Parameters:
-
[in] | _size | - initial size of the container |
Bag constructor with a specified hash function.
- Parameters:
-
[in] | hashFunction | - hash function |
[in] | _size | - initial size of the container |
Bag copy constructor.
- Parameters:
-
[in] | hashTable | - hashTable to copy (including the hash function) |
Bag constructor with a specified hash function and a container.
- Parameters:
-
[in] | hashFunction | - hash function |
[in] | container | - container, which will be used to construct the bag |
Member Function Documentation
Assignment operator.
- Parameters:
-
[in] | hashTable | - hashTable to copy (including the hash function) |
bool add |
( |
const T & |
item |
) |
[inline, virtual] |
Adds a new item to the bag.
- Parameters:
-
- Returns:
- true, if item was added successfully, else false
Reimplemented from THashTable< T >.
bool add |
( |
const T & |
item, |
|
|
int32 |
numCopies | |
|
) |
| | [inline, virtual] |
Adds a number of copies of a new item to the bag.
- Parameters:
-
[in] | item | - item to add |
[in] | numCopies | - number of copies |
- Returns:
- true, if items were added successfully, else false
bool remove |
( |
const T & |
item |
) |
[inline, virtual] |
Removes the first occurrence of an item from the bag.
- Parameters:
-
[in] | item | - item to remove |
- Returns:
- true, if item was removed successfully, else false
Reimplemented from THashTable< T >.
bool remove |
( |
const T & |
item, |
|
|
int32 |
numCopies | |
|
) |
| | [inline, virtual] |
Removes a number of copies of an item from the bag.
- Parameters:
-
[in] | item | - item to remove |
[in] | numCopies | - number of copies |
- Returns:
- true, if items were removed successfully, else false
void removeAll |
( |
const T & |
item |
) |
[inline, virtual] |
Removes all occurrences of the specific item from the bag.
- Parameters:
-
[in] | item | - item to remove |
- Returns:
- true, if all occurrences were removed successfully, else false
void removeAll |
( |
|
) |
[inline, virtual] |
int32 getCount |
( |
const T & |
item |
) |
[inline] |
Number of occurrences (cardinality) of the given item.
- Parameters:
-
[in] | item | - item to count |
- Returns:
- number of occurrences
THashSet< T > * createUniqueSet |
( |
|
) |
[inline] |
Creates a hash set of unique items.
The hash set contains exactly one copy of each item in the bag
- Returns:
- hash set